//
//  Tips.m
//
//  Created by yinqy on 15/1/10.
//  Copyright (c) 2015年  All rights reserved.
//

#import "DialogUtils.h"

@implementation DialogUtils
+(void)showTipsWithView:(UIView *)view String:(NSString *)string{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view==nil?[UIApplication sharedApplication].keyWindow:view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.labelText = string;
    hud.margin = 30.f;
    hud.cornerRadius = 7;
    //设置允许用户与后面的界面交互
    hud.userInteractionEnabled = NO;
    hud.removeFromSuperViewOnHide = YES;
    [hud hide:YES afterDelay:2];
}

+(MBProgressHUD *)showLoadingWithView:(UIView *)view{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view==nil?[UIApplication sharedApplication].keyWindow:view animated:YES];
    hud.labelText = @"加载中...";
    hud.minSize = CGSizeMake(100, 100);
    hud.cornerRadius = 7;
    hud.removeFromSuperViewOnHide = YES;
    return hud;
}

+(MBProgressHUD *)showLoadingWithView:(UIView *)view title:(NSString *)title{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view==nil?[UIApplication sharedApplication].keyWindow:view animated:YES];
    hud.labelText = title;
    hud.minSize = CGSizeMake(100, 100);
    hud.cornerRadius = 7;
    hud.removeFromSuperViewOnHide = YES;
    return hud;
}

+(void)showTips:(NSString *)string{
    [self showTipsWithView:nil String:string];
}

+(MBProgressHUD *)showLoding{
    return  [self showLoadingWithView:nil];
}

+(void)hideLoding{
    [MBProgressHUD hideHUDForView:[UIApplication sharedApplication].keyWindow animated:NO];
}
@end
